﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMasterPage.master"  EnableEventValidation="false" CodeFile="CreateTicketFromProfiles.aspx.cs" Inherits="User_CreateTicketFromProfiles" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content runat="server" ID="Content0" ContentPlaceHolderID="PageTitle">
    Create Ticket
</asp:Content>

<asp:Content runat="Server" ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder">

    <style type="text/css">
        #faqbg
        {
            background-color: #666666;
            position: absolute;
            z-index: 99;
            left: 0;
            top: 0;
            display: none;
            width: 100%;
            height: 1000px;
            opacity: 0.5;
            filter: alpha(opacity=50);
            -moz-opacity: 0.5;
        }
        #faqdiv
        {
            position: fixed;
            width: 900px;
            height: auto;
            left: 50%;
            top: 50%;
            margin-left: -440px;
            margin-top: -120px;
            z-index: 1000;
            background-color: #fff;
            border: 1px #8FA4F5 solid;
            padding: 1px;
            display: block;
        }
        #faqdiv h2
        {
            height: 25px;
            font-size: 14px;
            background-color: #8FA4F5;
            position: relative;
            padding-left: 10px;
            line-height: 25px;
        }
        #faqdiv h2 a
        {
            position: absolute;
            right: 5px;
            font-size: 12px;
            color: #FF0000;
        }
        #faqdiv .form
        {
            padding: 10px;
        }
    </style>

    <script language="javascript" type="text/javascript">

        function ShowReminderInfo(obj, profileType) {
            document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_txtProfileType").value = profileType;
            document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_txtProfileCode").value = $(obj).attr("ProfileCode");
            var ddlCategory = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlCategory");
            var ddlServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlServiceType");
            if (profileType == 'Client') {
                document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_txtChargeableCode").value = $(obj).attr("ChargeableCode");
                var ddlClientCategory = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlClientCategory");
                var ddlClientServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlClientServiceType");
                copyCategoryDLL(ddlClientCategory, ddlCategory);
                copyServiceTypeDLL(ddlClientServiceType, ddlServiceType, "");
            }
            else if (profileType == 'NonClient') {
                var ddlNonClientCategory = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlNonClientCategory");
                var ddlNonClientServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlNonClientServiceType");
                copyCategoryDLL(ddlNonClientCategory, ddlCategory);
                copyServiceTypeDLL(ddlNonClientServiceType, ddlServiceType, "");
            }

            $("#faqbg").css({ display: "block", height: $(document).height() });
            var yscroll = document.documentElement.scrollTop;
            $("#faqdiv").css("display", "block");
            $('body').css("overflow", "hidden");
            document.documentElement.scrollTop = 0;
            return false;
        }

        function selectIndexChanged(obj, source) {
            var txtProfileType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_txtProfileType");
            if (source == "Category") {
                var ddlCategory = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlCategory");
                var ddlServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlServiceType");
                var ddlClientServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlClientServiceType");
                var ddlNonClientServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlNonClientServiceType");

                var btn = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_btnConfirm");
                btn.disabled = true;

                var selValue = ddlCategory.options[ddlCategory.selectedIndex].value;
                if (txtProfileType.value == "Client") {
                    copyServiceTypeDLL(ddlClientServiceType, ddlServiceType, selValue);
                }
                else if (txtProfileType.value == "NonClient") {
                    copyServiceTypeDLL(ddlClientServiceType, ddlServiceType, selValue);
                }
            }
            if (source == "ServiceType") {
                var ddlServiceType = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_ddlServiceType");
                var selValue = ddlServiceType.options[ddlServiceType.selectedIndex].value;
                var btn = document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_btnConfirm");

                if (selValue != "") {
                    document.getElementById("MainContentPlaceHolder_MainContentPlaceHolder_txtServiceTypeCode").value = selValue;
                    btn.disabled = false;
                }
                else {
                    btn.disabled = true;
                }
            }
        }

        function copyCategoryDLL(source, des) {
            removeDLL(des);
            var tOption = document.createElement("Option");
            tOption.text = "Please select category first.";
            tOption.value = "";
            des.add(tOption);

            for (var i = 0; i < source.options.length; i++) {
                tOption = document.createElement("Option");
                tOption.text = source.options[i].text;
                tOption.value = source.options[i].value;
                des.add(tOption);
            }
        }

        function copyServiceTypeDLL(source, des, categoryCode) {
            removeDLL(des);
            var tOption = document.createElement("Option");
            tOption.text = "Please select...";
            tOption.value = "";
            des.add(tOption);

            for (var i = 0; i < source.options.length; i++) {
                var serviceTypeCode = source.options[i].value;
                var serviceTypeText = source.options[i].text;
                if (serviceTypeCode.startsWith(categoryCode)) {
                    tOption = document.createElement("Option");
                    tOption.text = serviceTypeText;
                    tOption.value = serviceTypeCode;
                    des.add(tOption);
                }
            }
        }

        function removeDLL(obj) {
            for (i = obj.options.length; i > 0; i--) {
                obj.options.remove(i - 1);
            }
        }

    </script>
    <asp:TextBox ID="txtChargeableCode" runat="server" Text="" style="display: none"></asp:TextBox>
    <asp:TextBox ID="txtProfileCode" runat="server" Text="" style="display: none"></asp:TextBox>
    <asp:TextBox ID="txtProfileType" runat="server" Text="" style="display: none"></asp:TextBox>
    <asp:TextBox ID="txtServiceTypeCode" runat="server" Text="" style="display: none"></asp:TextBox>

    <div id="faqbg">
    </div>
    <div id="faqdiv" style="display: none">
        <table style="background-color: #FFFFFF;">
            <tr>
                <td style="width: 10px">
                    &nbsp;
                </td>
                <td>
                    <div id="div1" runat="server" style="text-align: left; width: 860px;">
                        <asp:Panel ID="panelConfirmInfo" runat="server" class="clsConfirmInfo">
                            <div>
                                &nbsp;
                            </div>
                            <div style="padding-left: 4px;">
                            </div>
                            <div style="line-height: 10px;">
                                &nbsp;
                            </div>
                            <div>
                                <table>
                                    <tr>
                                        <td>
                                            Category
                                        </td>
                                        <td>
                                             <asp:DropDownList ID="ddlCategory" runat="server" ></asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Service type
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlServiceType" runat="server"></asp:DropDownList>
                                        </td>
                                    </tr>
                                </table>
                                <asp:DropDownList ID="ddlClientCategory" runat="server" style="display: none"></asp:DropDownList> 
                                <asp:DropDownList ID="ddlClientServiceType" runat="server" style="display: none"></asp:DropDownList> 
                                <asp:DropDownList ID="ddlNonClientCategory" runat="server" style="display: none"></asp:DropDownList> 
                                <asp:DropDownList ID="ddlNonClientServiceType" runat="server" style="display: none"></asp:DropDownList>                                
                            </div>
                            <div style="line-height: 20px;">
                                &nbsp;
                            </div>
                            <div style="padding-left: 4px; text-align: center;">
                                <asp:Button ID="btnConfirm" runat="server" Text="Confirm and submit"  OnClick="btnCreateTicket_Click" CssClass="FormButton2013" Enabled="false" />
                                &nbsp;
                                <asp:Button ID="btnCancel" runat="server" Text="Cancel and return to profiles" CssClass="FormButton2013" />
                            </div>
                        </asp:Panel>
                    </div>
                </td>
                <td style="width: 10px">
                    &nbsp;
                </td>
            </tr>
        </table>
    </div>

    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                <asp:TabContainer ID="TabContainer1" runat="server" CssClass="MyTabStyle" ActiveTabIndex="0">
                    <asp:TabPanel ID="TabPanel1" runat="server" >
                        <HeaderTemplate>
                            Client-related profiles
                        </HeaderTemplate>
                        <ContentTemplate>
                            <p style="padding-bottom: 20px; padding-top: 10px">
                            All opportunities that you can access are listed below. Select the opportunity you want to use and create a ticket<br>
                            If your opportunity has a chargeable code, the chargeable code is shown under the corresponding opportunity <br>
                            If you do not have a chargeable for your engagement yet, select "Chargeable TBD" under the corresponding opportunity<br>
                            Contact your opportunity manager to obtain access to opportunities that you cannot see in this screen (see My profile item header for more details)                                
                            </p>
                            <asp:Panel ID="panelChargeable" runat="server">
                                <asp:Repeater ID="rptChargeable" runat="server" OnItemDataBound="rptChargeable_ItemDataBound">
                                    <HeaderTemplate>
                                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                            <tr>
                                                <td class="RepeaterTableHead">Type
                                                </td>
                                                <td class="RepeaterTableHead">Profile
                                                </td>
                                                <td class="RepeaterTableHead">Chargeable to
                                                </td>
                                                <td class="RepeaterTableHead">Status
                                                </td>
                                                <td>&nbsp;
                                                </td>
                                            </tr>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td class="<%#(Container.ItemIndex%2==0)?"RepeaterTableRow":"RepeaterTableRowAlternative"%>">
                                                <asp:Label ID="lblType" runat="server" ></asp:Label>
                                            </td>
                                            <td class="<%#(Container.ItemIndex%2==0)?"RepeaterTableRow":"RepeaterTableRowAlternative"%>">
                                                <asp:Label ID="lblProfile" runat="server" ></asp:Label>
                                            </td>
                                            <td class="<%#(Container.ItemIndex%2==0)?"RepeaterTableRow":"RepeaterTableRowAlternative"%>">
                                                <asp:Label ID="lblChargeableToCode" runat="server"  ForeColor="#007C92" Font-Bold="true"></asp:Label>
                                                <br />
                                                <asp:Label ID="lblChargeableDesc" runat="server" ></asp:Label>
                                                <br />
                                                <br />
                                                <asp:Label ID="lblStatus" runat="server" ></asp:Label>
                                            </td>
                                            <td class="<%#(Container.ItemIndex%2==0)?"RepeaterTableRow":"RepeaterTableRowAlternative"%>">
                                                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/pencil.gif" ImageAlign="Bottom" Visible="false"/>
                                                <asp:Label ID="lblTeamInherit" runat="server"></asp:Label>
                                            </td>
                                            <td>
                                                <span style="padding-left: 10px">
                                                    <asp:Button ID="BtnCreateTicket" runat="server" CssClass="FormButton2013" OnClientClick="return ShowReminderInfo(this, 'Client');"  />
                                                </span>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Panel ID="panelFooter" runat="server" Visible="false">
                                            <tr>
                                                <td class="RepeaterTableRow" colspan="4" style="text-align: center">The list is empty
                                                </td>
                                                <td>&nbsp;
                                                </td>
                                            </tr>
                                        </asp:Panel>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>
                                <div style="line-height: 30px">
                                    &nbsp;
                                </div>
                                <div>
                                    <p>
                                    Cannot find your profile? Please contact your Opportunity/Engagement in charge.                                       
                                    </p>
                                </div>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:TabPanel>
                    <asp:TabPanel ID="TabPanel2"  runat="server">
                        <HeaderTemplate>
                            Non client-related profiles
                        </HeaderTemplate>
                        <ContentTemplate>
                            <p style="padding-bottom: 20px; padding-top: 10px">
                                For services not specific to client, please create tickets from the corresponding
                                profile below:
                            </p>
                            <asp:Panel ID="panelNoClientProfile" runat="server">
                                <asp:Repeater ID="rptNoClientProfile" runat="server" OnItemDataBound="rptNoClientProfile_ItemDataBound">
                                    <HeaderTemplate>
                                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                            <tr>
                                                <td class="RepeaterTableHead">Type
                                                </td>
                                                <td class="RepeaterTableHead">Profile
                                                </td>
                                                <td>&nbsp;
                                                </td>
                                            </tr>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td class="<%#(Container.ItemIndex%2==0)?"RepeaterTableRow":"RepeaterTableRowAlternative"%>">
                                                <asp:Label ID="lblType" runat="server"></asp:Label>
                                            </td>
                                            <td class="<%#(Container.ItemIndex%2==0)?"RepeaterTableRow":"RepeaterTableRowAlternative"%>">
                                                <asp:Label ID="lblProfile" runat="server"></asp:Label>
                                            </td>
                                            <td>
                                                <span style="padding-left: 10px">                                                    
                                                    <asp:Button ID="btnCreateNonClientTicket" runat="server" CssClass="FormButton2013" OnClientClick="return ShowReminderInfo(this, 'NonClient');"  />
                                                </span>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:TabPanel>
                </asp:TabContainer>
            </td>
        </tr>
    </table>
</asp:Content>

